//
//  PictureCell.m
//  王雷Sinoweibo
//
//  Created by wanglei on 16/11/24.
//  Copyright © 2016年 wanglei. All rights reserved.
//

#import "PictureCell.h"

@implementation PictureCell

-(instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    [self setupUi];
    return self;
}

- (void)setImageURL:(NSURL *)imageURL{
    _imageURL = imageURL;
    [_iconView sd_setImageWithURL:_imageURL];
    NSLog(@"_imageURL = %@",_imageURL);
}

- (void)setupUi{
//    注意此处的imageview相当重要,相当于给_iconView进行实例化,否则是不会将找照片加载上去的
    UIImageView *imageview = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"timeline_icon_like"]];
// contentMode表示iamgeview的显示样式,UIViewContentModeScaleAspectFill表示缩放视图进行填充,这样可以保证视图的显示不会失真
    imageview.contentMode = UIViewContentModeScaleAspectFill;
//    设置手动剪裁
    imageview.clipsToBounds = true;
    _iconView = imageview;
    NSLog(@"_iconView = %@",_iconView.image);
    if (_iconView.image == nil) {
        return;
    }
    [self.contentView addSubview:_iconView];
    [_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
}
@end
